﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TKToXML.Models;
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;

namespace TKToXML.Persistence.ClassMaps
{
    public class HoaDonChiTietMap : ClassMapping<HoaDonChiTiet>
    {
        public HoaDonChiTietMap()
        {            
            Table("EDHOADONCT");
            ComposedId(m =>
            {
                m.Property(x => x.NamChungTu, map => map.Column("Nam_CT"));
                m.Property(x => x.SoChungTu, map => map.Column("So_CT"));
                m.Property(x => x.SoThuTu, map => map.Column("So_TT"));
            });

            Property(x => x.MaHS, map => map.Column("Ma_HS"));
            Property(x => x.MaHangHoa, map => map.Column("Ma_HH"));
            Property(x => x.TenHangHoa, map => map.Column("Ten_HH"));
            Property(x => x.MaNuocXuatXu, map => map.Column("Ma_NU_XX"));
            Property(x => x.MaDonViTinh, map => map.Column("Ma_DVT"));
            Property(x => x.SoLuong, map => map.Column("SoLuong"));
            Property(x => x.MaNguyenTe, map => map.Column("Ma_NT"));
            Property(x => x.DonGiaNguyenTe, map => map.Column("DonGia_NT"));
            Property(x => x.TriGiaNguyenTe, map => map.Column("TriGia_NT"));

            ManyToOne(x => x.HoaDon, map =>
            {
                map.Column("HoaDonId");
                map.Class(typeof(HoaDon));
                map.Cascade(Cascade.All);
            });
        }
    }
}
